home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat1 / xargs.z / xargs
Text File  |  1998-10-20  |  11KB  |  199 lines

  1.  
  2.  
  3.  
  4. XXXXAAAARRRRGGGGSSSS((((1111))))                                                              XXXXAAAARRRRGGGGSSSS((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      xargs - construct argument list(s) and execute command
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      xxxxaaaarrrrggggssss [options] [ command [initial-arguments] ]
  13.  
  14. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  15.      _xxxx_aaaa_rrrr_gggg_ssss constructs a command line consisting of the _c_o_m_m_a_n_d and _i_n_i_t_i_a_l-
  16.      _a_r_g_u_m_e_n_t_s operands specified followed by as many arguments read in
  17.      sequence from standard input as will fit in length and number constraints
  18.      specified by the options.  _xxxx_aaaa_rrrr_gggg_ssss then invokes the constructed command
  19.      line and waits for its completion. This sequence is repeated until an
  20.      end-of-file condition is detected on standard input or an invocation of a
  21.      constructed command line returns an exit status of 255.
  22.  
  23.      _c_o_m_m_a_n_d, which may be a shell file, is searched for, using one's $$$$PPPPAAAATTTTHHHH.
  24.      If _c_o_m_m_a_n_d is omitted, ////bbbbiiiinnnn////eeeecccchhhhoooo is used.
  25.  
  26.      Arguments read in from standard input are defined to be contiguous
  27.      strings of characters delimited by one or more blanks, tabs, or new-
  28.      lines; empty lines are always discarded.  Blanks and tabs may be embedded
  29.      as part of an argument if escaped or quoted.  Characters enclosed in
  30.      quotes (single or double) are taken literally, and the delimiting quotes
  31.      are removed.  Outside of quoted strings a backslash (\\\\) will escape the
  32.      next character.
  33.  
  34.      The generated command line length will be the sum of the size in bytes of
  35.      the command name and each argument treated as strings, including a null
  36.      byte terminator for each of these strings. The _xxxx_aaaa_rrrr_gggg_ssss command will limit
  37.      the command line length such that when the command line is invoked, the
  38.      combined argument and environment lists will not exceed ARG_MAX-2048
  39.      bytes. Within this constraint, if neither the _----_nnnn nor the _----_ssss option is
  40.      specified, the default command line length will be at least LINE_MAX.
  41.  
  42. OOOOPPPPTTTTIIIIOOOONNNNSSSS
  43.      ----LLLL_n_u_m_b_e_r  _c_o_m_m_a_n_d is executed for each non-empty _n_u_m_b_e_r lines of
  44.                arguments from standard input.  The last invocation of _c_o_m_m_a_n_d
  45.                will be with fewer lines of arguments if fewer than _n_u_m_b_e_r
  46.                remain.  A line is considered to end with the first new-line
  47.                unless the last character of the line is a blank or a tab; a
  48.                trailing blank/tab signals continuation through the next non-
  49.                empty line.
  50.  
  51.      _----_llll[_n_u_m_b_e_r]
  52.                Same as -L, except: if _n_u_m_b_e_r is omitted, 1 is assumed; option
  53.                ----xxxx is forced.
  54.  
  55.      ----IIII_r_e_p_l_s_t_r Insert mode:  _c_o_m_m_a_n_d is executed for each line from standard
  56.                input, taking the entire line as a single arg, inserting it in
  57.                _i_n_i_t_i_a_l-_a_r_g_u_m_e_n_t_s for each occurrence of _r_e_p_l_s_t_r.  A maximum of
  58.                5 arguments in _i_n_i_t_i_a_l-_a_r_g_u_m_e_n_t_s may each contain one or more
  59.                instances of _r_e_p_l_s_t_r.  Blanks and tabs at the beginning of each
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. XXXXAAAARRRRGGGGSSSS((((1111))))                                                              XXXXAAAARRRRGGGGSSSS((((1111))))
  71.  
  72.  
  73.  
  74.                line are ignored.  Constructed arguments may not grow larger
  75.                than what the kernel _n_c_a_r_g_s value allows (the default as
  76.                shipped is 20480), including room for pointers.  This may be
  77.                further reduced, depending on environment size and other
  78.                arguments), and option ----xxxx is forced.
  79.  
  80.      _----_iiii[_r_e_p_l_s_t_r]
  81.                Same as _----_IIII except that {{{{}}}} is assumed for _r_e_p_l_s_t_r if omitted.
  82.                The _----_IIII and _----_iiii options are mutually exclusive; the last one
  83.                specified takes effect.
  84.  
  85.      ----nnnn_n_u_m_b_e_r  Execute _c_o_m_m_a_n_d using as many standard input arguments as
  86.                possible, up to _n_u_m_b_e_r arguments maximum.  Fewer arguments will
  87.                be used if their total size is greater than _s_i_z_e characters,
  88.                and for the last invocation if there are fewer than _n_u_m_b_e_r
  89.                arguments remaining.  In any case, a maximum of 1024 arguments
  90.                will be passed per command invocation.  This is further reduced
  91.                by any extra command arguments given on the xargs command line.
  92.                If option ----xxxx is also coded, each _n_u_m_b_e_r arguments must fit in
  93.                the _s_i_z_e limitation, else _x_a_r_g_s terminates execution. The _----_LLLL,
  94.                _----_llll and _----_nnnn options are mutually exclusive; the last one
  95.                specified takes effect.
  96.  
  97.      ----tttt        Trace mode: The _c_o_m_m_a_n_d and each constructed argument list are
  98.                echoed to file descriptor 2 just prior to their execution.
  99.  
  100.      ----pppp        Prompt mode: The user is asked whether to execute _c_o_m_m_a_n_d each
  101.                invocation. Trace mode (----tttt) is turned on to print the command
  102.                instance to be executed, followed by a ????............ prompt.  A reply of
  103.                yyyy (optionally followed by anything) will execute the command;
  104.                anything else, including just a carriage return, skips that
  105.                particular invocation of _c_o_m_m_a_n_d.
  106.  
  107.      ----xxxx        Causes xxxxaaaarrrrggggssss to terminate if any argument list would be greater
  108.                than _s_i_z_e characters; ----xxxx is forced by the options ----iiii and ----llll.
  109.                When neither of the options ----iiii, ----llll, or ----nnnn are coded, the total
  110.                length of all arguments must be within the _s_i_z_e limit.
  111.  
  112.      ----ssss_s_i_z_e    Invoke command using as many standard input arguments as
  113.                possible yielding a command line length less than _s_i_z_e (a
  114.                positive decimal integer) bytes. Fewer arguments will be used
  115.                if the total number of arguments (lines) exceeds that specified
  116.                by the _----_nnnn (_----_LLLL) option or end of file is encoutered on standard
  117.                input before _s_i_z_e bytes are accumulated.  The maximum _s_i_z_e
  118.                depends partly on the size of the environment, but is limited
  119.                to a maximum of the kernel value of _n_c_a_r_g_s (the default as
  120.                shipped is 20480), including room for pointers. If ----ssss is not
  121.                coded, the maximum is taken as the default.
  122.  
  123.      _----_EEEE_e_o_f_s_t_r  Specify a logical end-of-file string to replace the default
  124.                underscore. xxxxaaaarrrrggggssss reads standard input until either end-of-file
  125.                or the logical EEEEOOOOFFFF string is encountered.
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. XXXXAAAARRRRGGGGSSSS((((1111))))                                                              XXXXAAAARRRRGGGGSSSS((((1111))))
  137.  
  138.  
  139.  
  140.      _----_eeee[_e_o_f_s_t_r]
  141.                Same as _----_EEEE except that the option ----eeee with no _e_o_f_s_t_r coded turns
  142.                off the logical EEEEOOOOFFFF string capability (underbar is taken
  143.                literally).
  144.  
  145.      Note: The _----_eeee, _----_iiii and _----_llll take optional option-arguments that cannot be
  146.      separate arguments.
  147.  
  148.      xxxxaaaarrrrggggssss will terminate if either it receives a return code of ----1111 from, or
  149.      if it cannot execute, _c_o_m_m_a_n_d.  When _c_o_m_m_a_n_d is a shell program, it
  150.      should explicitly _e_x_i_t (see _s_h(1)) with an appropriate value to avoid
  151.      accidentally returning with ----1111.
  152.  
  153. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  154.      The following will move all files from directory $1 to directory $2, and
  155.      echo each move command just before doing it:
  156.  
  157.                ls $1 | xargs -i -t mv $1/{} $2/{}
  158.  
  159.      or
  160.                ls $1 | xargs -I /{} -t mv $1/{} $2/{}
  161.  
  162.      The following will combine the output of the parenthesized commands onto
  163.      one line, which is then echoed to the end of file _l_o_g:
  164.  
  165.                (logname; date; echo $0 $*) | xargs >>log
  166.  
  167.      The user is asked which files in the current directory are to be archived
  168.      and archives them into _a_r_c_h (1.) one at a time, or (2.) many at a time.
  169.  
  170.                1.  ls | xargs -p -l ar r arch
  171.                2.  ls | xargs -p -l | xargs ar r arch
  172.  
  173.      The following will execute _d_i_f_f(1) with successive pairs of arguments
  174.      originally typed as shell arguments:
  175.  
  176.                echo $* | xargs -n2 diff
  177.  
  178. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  179.      _xxxx_aaaa_rrrr_gggg_ssss exits with 0 when all invocations of command returned exit status
  180.      zero.  _xxxx_aaaa_rrrr_gggg_ssss exits with 126 when the command specified was found but
  181.      could not be invoked. _xxxx_aaaa_rrrr_gggg_ssss exits with 127 when the command specified
  182.      could not be found.
  183.  
  184. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  185.      sh(1).
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.